package com.handu.luna.core.domain.goods;

import java.util.Date;
import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.handu.luna.core.domain.BaseRepository;

public interface BrandGeneralInfoRepository extends JpaRepository<BrandGeneralInfo, Long>, BaseRepository<BrandGeneralInfo>,JpaSpecificationExecutor<BrandGeneralInfo>{
	
	/**
	 * 查询通用信息
	 * @return
	 */
	@Query("select g from BrandGeneralInfo g ")
	public List<BrandGeneralInfo> findDisplayList();
	
	/**
	 * 查询通用信息(通过品牌ID)
	 * @param brandId 品牌ID
	 * @return
	 */
	@Query("select g from BrandGeneralInfo g where g.brandId = :brandId")
	public List<BrandGeneralInfo> findByBrandId(@Param("brandId") long brandId);
	
	/**
	 * 查询通用信息(未过期）
	 * @param currentDate 当前时间
	 * @return
	 */
	 
	@Query("select g from BrandGeneralInfo g where g.endDate > :currentDate ")
	public List<BrandGeneralInfo> findByUnexpired(@Param("currentDate") Date currentDate);
	
	/**
	 * 查询通用信息(未过期，通过品牌ID）
	 * @param brandId 品牌ID
	 * @param currentDate 当前时间
	 * @return
	 */
	@Query("select g from BrandGeneralInfo g where g.endDate > :currentDate and g.brandId = :brandId")
	public List<BrandGeneralInfo> findByBrandIdAndUnexpired(@Param("brandId") long brandId,@Param("currentDate") Date currentDate);
	
}
